package com.action.library;

import com.bean.library.Student;
import com.dao.DaoManager;
import com.dao.library.StudentDao;

public class SRegisterAction {
	public Student studentRegister(Student studentRegist){
		Student student = null;
		DaoManager dm = DaoManager.getInstance();
		StudentDao studentDao = dm.getDao(StudentDao.class);
		try
		{
			dm.begin();
			student = studentDao.registerStudentAccount(studentRegist);
			dm.commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally 
		{
			dm.end();
		}
		return student;
	}
	public Student studentRegister(String studentId, String password,
			String studentName, String academy, String major,
			String yearOfEntrance)
	{
		DaoManager dm = DaoManager.getInstance();
		StudentDao studentDao = dm.getDao(StudentDao.class);
		Student student = null;	
		try
		{
			dm.begin();
			student = studentDao.registerStudentAccount(studentId, password,
					studentName, academy, major,
					yearOfEntrance);
			dm.commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally 
		{
			dm.end();
		}
		return student;
	}
}
